var app = getApp();
var api = require('../../api.js');
Page({
  data: {

  },
  // 我的付款码
  payment_code: function() {
    wx.showActionSheet({
      itemList: ['次卡支付', '余额支付'],
      success: function(res) {
        console.log(res.tapIndex);
        if (res.tapIndex == 0) {
          wx.navigateTo({
            url: '/pages/mine/payment_code?id=0',
          })
        }
        if (res.tapIndex == 1) {
          wx.navigateTo({
            url: '/pages/mine/payment_code?id=1',
          })
        }
      }
    })

  },

  onLoad() {

  },
  onShow() {
    var that = this
    that.setData({
      // is_manage:false
      is_manage: wx.getStorageSync('is_manage'),
    }) 
    if (wx.getStorageSync('real_name')) {
      app.ajax(api.member_info, {
        rd_session: wx.getStorageSync('rd_session'),
      }, (res) => {
        console.log(res)
        that.setData({
          info: res.data.lists
        })
      });
    } else {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }   
  },
  // 我的资料
  go_info: function() {
    wx.navigateTo({
      url: '/pages/mine/info',
    })
  },
  // 核销
  write_off: function() {
      // 允许从相机和相册扫码
      var that = this;
      wx.scanCode({
        success(res) {
          console.log(res)
          if(res.path){
            var arr = res.path.split('=')
            var idnum = arr[1].split('&')
            var type = arr[2].split('&')
            wx.navigateTo({
              url: `/pages/write_off/index?id=${idnum[0]}&type=${type[0]}&three=${arr[3]}`,
            })
          }else{
            wx.showToast({
              title: '请扫描正确的二维码',
              icon:"none"
            })
          }
          
         //
        }
      })
   
  },
  // 预约管理
  go_arrange_list: function() {
    wx.navigateTo({
      url: '/pages/arrange/list',
    })
  },
  // 发布活动
  go_add_active: function() {
    wx.navigateTo({
      url: '/pages/active/add',
    })
  },
  // 活动管理
  go_active_edit: function() {
    wx.navigateTo({
      url: '/pages/active/list',
    })
  },
  // 充值设置
  go_recharge_set: function() {
    wx.navigateTo({
      url: '/pages/recharge/set',
    })
  },
  // 充值管理
  go_recharge: function() {
    wx.navigateTo({
      url: '/pages/recharge/list',
    })
  },
  // 次卡管理
  go_num_card: function() {
    wx.navigateTo({
      url: '/pages/num_card/list',
    })
  },
  // 核销记录/消费记录
  go_write_off_list: function() {
    wx.navigateTo({
      url: '/pages/write_off/list',
    })
  },
  go_consumption: function() {
    wx.navigateTo({
      url: '/pages/write_off/list',
    })
  },
  // 门店分布
  go_shop_list: function() {
    wx.navigateTo({
      url: '/pages/shop/list',
    })
  },



})